package com.swt.gap.controller;

import com.swt.gap.model.vo.TaskResultVO;
import com.swt.gap.service.AchievementTaskResultService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author tyh
 * @Date 2020/5/11 20:03
 */

@Api(tags = "604 战果相关")
@RestController
@RequestMapping("/achievement/taskResult")
@Slf4j
public class AchievementTastResultController {

    @Autowired
    private AchievementTaskResultService achievementTaskResultService;

    @GetMapping
    @ApiOperation(value = "获取任务名及其分析结果", notes = "获取任务名及其分析结果")
    @ApiImplicitParam(name = "keyword", dataType = "String",paramType = "query", value = "关键字")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = TaskResultVO.class, responseContainer = "List")})
    public ResponseEntity getTaskResult(String keyword){
        if (keyword != null){
            keyword = keyword.trim();

            if(keyword.length() > 20){
                keyword = keyword.substring(0,20);
            }
        }

        return ResponseEntity.ok(achievementTaskResultService.getTaskResults(keyword));
    }


}
